<!--# 
layout("/layout/default.html",{"menu":["settings","setting_list"],"breadcrumbs":[{"name":"配置列表",url:"setting/list"},{"name":(obj.data.config==null?"添加配置":"编辑配置")}]}){ 
 #-->
<link rel="stylesheet" href="${base!}/resources/kindeditor/themes/default/default.css" />
<div class="space-4"></div>
<div class="row">
	<div class="col-md-8 col-md-offset-2 col-sm-12">
		<div class="panel panel-info">
			<div class="panel-heading">
				<h3 class="panel-title">${obj.data.config==null ? "添加配置":"编辑配置"}</h3>
			</div>
			<div class="panel-body">
				<form id="configForm" class="cmxform form-horizontal adminex-form" novalidate="novalidate">
					<div class="form-group ">
						<label for="用户名" class="control-label col-lg-3">配置名 : </label>
						<div class="col-lg-9">
							<input class="form-control" type="text" placeholder="请输入配置名称" name="name" data-type='required' data-error='请输入配置名称' value="${obj.data.config.name!}"  />
						</div>
					</div>
					<div class="form-group ">
						<label class="control-label col-lg-3"> 配置值 : </label>
						<div class="col-lg-9">
							<input class="form-control" type="text" placeholder="请输入用户配置值" name="value" data-type='required' data-error='请输入用户配置值' value="${obj.data.config.value!}">
						</div>
					</div>
					<div class="form-group ">
						<label class="control-label col-lg-3"> 配置说明 : </label>
						<div class="col-lg-9">
							<textarea rows="10" id="description" name="description" class="form-control" placeholder="请填写配置说明">${obj.data.config.description!}</textarea>
						</div>
					</div>
					<input type="hidden" id="id" name="id" value="${obj.data.config.id!}">
					<div class="pull-right" style="margin-right: 45px">
						<button type="button" class="btn btn-sm btn-primary" onclick="save(this)">
							<i class="fa fa-save"></i> 提交
						</button>
						<a href="${base}/setting/list" class="btn btn-sm btn-default"> <i class="fa fa-undo"></i> 返回
						</a>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<script charset="utf-8" src="${base!}/resources/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="${base!}/resources/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="description"]', {
			uploadJson : getRootPath() + '/kind/upload'
		});
	})

	function save(btn) {
		$('#description').val(editor.html());
		if ($('#configForm').find('input').validation()) {//验证表单
			if ($('#id').val()) {
				$.post(getRootPath() + '/setting/edit', $('#configForm').serialize(), function(result) {
					if (result.operationState == 'SUCCESS') {
						location.href = getRootPath() + "/setting/list";
					} else {
						validationFail(result.data.reason, btn);
					}
				}, 'json');
			} else {
				$.post(getRootPath() + '/setting/add', $('#configForm').serialize(), function(result) {
					if (result.operationState == 'SUCCESS') {
						location.href = getRootPath() + "/setting/list";
					} else {
						validationFail(result.data.reason, btn);
					}
				}, 'json');
			}
		}
	}
</script>
<!--# } #-->